package com.sk.skplanet.commute.controllers;

import java.util.List;

import android.content.Context;
import android.graphics.Color;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TextView;

import com.sk.skplanet.commute.actions.Actions;
import com.sk.skplanet.commute.dao.StopInfoDao;
import com.sk.skplanet.commute.vo.Data;
import com.sk.skplanet.commute.vo.PointVo;
import com.sk.skplanet.commute.vo.StopInfoVo;

public class PointController {

	/**
	 * 북마크 항목 내 내부 위치, 버스정보를 담은 레이아웃 생성 메소드
	 * 
	 * @param : 북마크 액티비티의 컨텍스트
	 * @return : 내부 위치, 버스정보를 담은 레이아웃
	 */
	public static LinearLayout makePoint(Context context, PointVo pointVo) {

		// 포인트 레이아웃 설정 부분

		LinearLayout layout_point = new LinearLayout(context);
		layout_point.setOrientation(LinearLayout.VERTICAL);
		LayoutParams layoutParams_layout_point = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
				LayoutParams.WRAP_CONTENT);
		layoutParams_layout_point.setMargins(0, Actions.DPFromPixel(5), 0, Actions.DPFromPixel(5));
		layout_point.setPadding(Actions.DPFromPixel(10), Actions.DPFromPixel(10), Actions.DPFromPixel(10),
				Actions.DPFromPixel(10));
		layout_point.setLayoutParams(layoutParams_layout_point);
		layout_point.setBackgroundColor(Color.parseColor(Data.layout_pointColor));

		{// 포인트 텍스트뷰 설정 부분
			TextView textview_point = new TextView(context);
			textview_point.setText(pointVo.getName());
			textview_point.setTextColor(Color.parseColor(Data.textview_routeColor));
			textview_point.setTextSize((float) Actions.DPFromPixel(15));

			android.view.ViewGroup.LayoutParams layoutParams_textview_route = new LayoutParams(
					LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
			textview_point.setLayoutParams(layoutParams_textview_route);
			layout_point.addView(textview_point);
		}

		{// 인포 레이아웃 설정 부분

			List<StopInfoVo> list = StopInfoDao.selectInfo();

			for (StopInfoVo infoVo : list) {
				if (pointVo.getId() == infoVo.getPoint_id()) layout_point.addView(StopInfoController.makeInfo(context,
						infoVo));
			}

		}

		return layout_point;
	}
}
